package ahblue.cn.tanzi.ui.person.pay;

import android.content.Context;
import android.widget.Toast;

import com.google.gson.annotations.SerializedName;

import java.io.Serializable;

import ahblue.cn.tanzi.data.source.ApiCallback;
import ahblue.cn.tanzi.data.source.RemoteRepository;

/**
 * @author pink-jackstraw
 * @date 2018/12/07
 * @describe
 */
public class WAPayNode implements Serializable {


    private String appid;
    private String partnerid;
    private String prepayid;
    @SerializedName("package")
    private String packageX;
    private String noncestr;
    private String timestamp;
    private String sign;

    public String getAppid() {
        return appid;
    }

    public void setAppid(String appid) {
        this.appid = appid;
    }

    public String getPartnerid() {
        return partnerid;
    }

    public void setPartnerid(String partnerid) {
        this.partnerid = partnerid;
    }

    public String getPrepayid() {
        return prepayid;
    }

    public void setPrepayid(String prepayid) {
        this.prepayid = prepayid;
    }

    public String getPackageX() {
        return packageX;
    }

    public void setPackageX(String packageX) {
        this.packageX = packageX;
    }

    public String getNoncestr() {
        return noncestr;
    }

    public void setNoncestr(String noncestr) {
        this.noncestr = noncestr;
    }

    public String getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(String timestamp) {
        this.timestamp = timestamp;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public static void pay(Context context, String token, String order_sn, String payment_code, final VertifyListener loginListener) {
        RemoteRepository repo = RemoteRepository.getsInstance();
        repo.pay(token,order_sn,payment_code, new ApiCallback<WAPayNode>(){
            @Override
            public void onSuccess(WAPayNode data) {
                if (null!=loginListener){
                    loginListener.conver(data);
                }
            }

            @Override
            public void onFailed(String errorMsg) {
                Toast.makeText(context,errorMsg,Toast.LENGTH_LONG).show();
                if (null!=loginListener){
                    loginListener.conver(null);
                }
            }
        });
    }

    public static void payVip(Context context, String token, String order_sn, String payment_code, final VertifyListener loginListener) {
        RemoteRepository repo = RemoteRepository.getsInstance();
        repo.payVip(token,order_sn,payment_code, new ApiCallback<WAPayNode>(){
            @Override
            public void onSuccess(WAPayNode data) {
                if (null!=loginListener){
                    loginListener.conver(data);
                }
            }

            @Override
            public void onFailed(String errorMsg) {
                Toast.makeText(context,errorMsg,Toast.LENGTH_LONG).show();
                if (null!=loginListener){
                    loginListener.conver(null);
                }
            }
        });
    }

    public interface VertifyListener {
        void conver(WAPayNode b);
    }


}
